/* eslint-disable prettier/prettier */
import React, { Component } from "react";
import { Button, Form, Spin, Checkbox, Input, message, Select, Radio, TimePicker, Icon, Affix } from "antd";
import AirLineServer from "../airline-server";
import CheckboxRadio from "../../hotel-config/components/checkbox-radio";
import AirLineUtil from "../airline-config-util";
import { messages,isEmptyObj } from "share/common";
import Condition from "components/condition";
import Selector from "components/selector";
import config from "config";

import moment from "moment";
import ReasonSetting from "../../reasons-config/reasons-setting";

const { If } = Condition;
const FormItem = Form.Item;
const TextArea = Input.TextArea;
const Option = Select.Option;
const GroupRadio = Radio.Group;

@Form.create()
class SetTravelControl extends Component {
  constructor(props) {
    super(props);
    this.state = {
      loading: false,
      isLowPriceControl: false, // 最低价控制
      isOpenApprovalControl: false, // 是否开启审批单管控
      isOpenTravelControl: false, // 是否开始差标管控
      settingData: {}, //
      flightTravelApprlvalControlDto: {}, // 审批单管控
      flightTravelStandardsControlDto: {}, // 差标管控
      airlineBlackList: [],
      airDatas: [],
    };
  }

  componentWillMount() {
    this.initData();
  }

  initData = () => {
    AirLineServer(this)
      .getAirControlData({ companyOid: this.props.companyOID })
      .then((res) => {
        const { body } = res.data;
        const { lowestPriceAirlinesBlackList } = body;
        this.setState(
          {
            flightTravelStandardsControlDto: body.travelStandardsControl,
            flightTravelApprlvalControlDto: body.travelApprovalControl,
            isLowPriceControl: body.controlLowestPrice,
            isOpenApprovalControl: body.enabledTravelApprovalControl,
            isOpenTravelControl: body.enabledTravelStandardsControl,
            settingData: body,
            airlineBlackList:
              lowestPriceAirlinesBlackList && lowestPriceAirlinesBlackList.length ? lowestPriceAirlinesBlackList : [""],
            airlineBlackListEnabled: body.enabledLowestPriceBlackList,
          },
          this.props.form.resetFields
        );
      });

    AirLineServer(this)
      .getAddedSupplierSigns({
        companyOid: this.props.companyOID,
        complete: true,
      })
      .then((res) => {
        if (res.data.body) {
          this.setState({
            airDatas: res.data.body || [],
          });
        } else {
          // 增加提示
          message.error(res.data.message);
        }
      });
  };

  onSaveSetting = () => {
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err) {
        const { settingData } = this.state;
        const params = AirLineUtil.formatControlData(settingData, values);
        const { airlineBlackList } = this.state;
        params.companyOid = this.props.companyOID;
        params.lowestPriceAirlinesBlackList = airlineBlackList.map((item) => {
          const { name, code } = item;
          return { name, code };
        });
        params.reasonForBeyondStandards = null;
        params.reasonForNotLowestPrice = null;

        AirLineServer(this)
          .saveAirControlData(params)
          .then((res) => {
            if (res.data.code === 200) {
              message.success(messages("supplier-1.key355") /* 保存成功*/);
            } else {
              message.error(res.data.message);
            }
          });
      }
    });
  };

  // 是否启用最低价
  onLowPriceChange = (values) => {
    this.setState({ isLowPriceControl: values.controlLowestPrice });
  };

  // 是否启用审批单管控
  onIsOpenApprovalControl = (eve) => {
    this.setState({ isOpenApprovalControl: eve.target.checked });
  };

  // 是否启用差标管控
  onIsOpenTravelControl = (eve) => {
    this.setState({ isOpenTravelControl: eve.target.checked });
  };

  // 审批单选人员组自定义检验
  approvalUserGroupChecked = (rule, value, callback) => {
    if (value.enabledNoApproval && value.noApprovalUserGroupId_ === "userId" && !value.noApprovalUserGroupId) {
      callback(messages("supplier-1.key408") /* 人员组必填*/);
    } else if (value.noApprovalUserGroupId_ === "all" || value.noApprovalUserGroupId) {
      callback();
    }
  };

  // 可见机票舱等自定义校验
  airClassUserGroupChecked = (rule, value, callback) => {
    if (
      value.enabledVisibleCabinClass &&
      value.visibleCabinClassUserGroupId_ === "userId" &&
      !value.visibleCabinClassUserGroupId
    ) {
      callback(messages("supplier-1.key408") /* 人员组必填*/);
    } else if (value.visibleCabinClassUserGroupId_ === "all" || value.visibleCabinClassUserGroupId) {
      callback();
    }
  };

  // 白名单自定义校验
  airWhiteListGroupChecked = (rule, value, callback) => {
    if (
      value.enabledNoControlLowestPrice &&
      value.noControlLowestPriceGroupId_ === "userId" &&
      !value.noControlLowestPriceGroupId
    ) {
      callback(messages("supplier-1.key408") /* 人员组必填*/);
    } else if (value.noControlLowestPriceGroupId_ === "all" || value.noControlLowestPriceGroupId) {
      callback();
    }
  };

  addAirlineBlackList = () => {
    const airlineBlackList = this.state.airlineBlackList;
    airlineBlackList[airlineBlackList.length] = "";
    this.setState({ airlineBlackList });
  };

  minusAirlineBlackList = (idx) => {
    const airlineBlackList = this.state.airlineBlackList;
    airlineBlackList.splice(idx, 1);
    this.setState({ airlineBlackList });
  };

  setAirline = (idx) => {
    setTimeout(() => {
      const airlineInfo = this.props.form.getFieldValue(`airlineName${idx}`);
      const airlineBlackList = this.state.airlineBlackList;
      airlineBlackList[idx] = airlineInfo;
      this.setState({ airlineBlackList });
    });
  };

  changEnabledLowestPriceBlackList = () => {
    this.setState({
      airlineBlackListEnabled: !this.state.airlineBlackListEnabled,
    });
  };

  render() {
    const { getFieldDecorator, getFieldValue } = this.props.form;
    const {
      isLowPriceControl,
      isOpenApprovalControl,
      settingData,
      isOpenTravelControl,
      airlineBlackList,
      airlineBlackListEnabled,
    } = this.state;
    const { flightTravelApprlvalControlDto, flightTravelStandardsControlDto, loading, airDatas } = this.state;
    // const enabledLowestPriceBlackList = this.props.form.getFieldValue(`enabledLowestPriceBlackList`)
    const airlineItem = {
      url: `${config.baseUrl}/location-service/api/airline/search/keyword?size=20`,
      label: (value) => `${value.name} ${value.code}`,
      key: "code",
      searchKey: "keyword",
    };

    const enabledAirDatas = airDatas.filter(({ isEnabled }) => isEnabled);
    return (
      <div className="airline-config-container">
        <Spin spinning={loading}>
          {!isEmptyObj(settingData) && <Form>
            <h2>{messages("supplier-1.key409") /* 员工可见机票舱等*/}</h2>
            <a className="a-line-bottom">
              {messages("supplier-1.key410") /* 默认所有员工只可见经济舱。启用后可设置部分员工可见头等舱/商务舱*/}
            </a>
            <FormItem>
              {getFieldDecorator("airClass_root", {
                rules: [{ validator: this.airClassUserGroupChecked }],
                initialValue: {
                  enabledVisibleCabinClass: settingData.enabledVisibleCabinClass,
                  visibleCabinClassUserGroupId:
                    settingData.visibleCabinClassUserGroupId != "all" ? settingData.visibleCabinClassUserGroupId : "",
                  visibleCabinClassUserGroupId_: settingData.visibleCabinClassUserGroupId === "all" ? "all" : "userId",
                },
              })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("airClass")} />)}
            </FormItem>
            <br />
            <a className="a-line-bottom">
              {messages("supplier-1.key411") /* 可设置航程时间超过N小时时，员工可见商务舱*/}
            </a>
            {AirLineUtil.singleCheckboxForm(
              getFieldDecorator,
              "enabledUpgradeCabinClassByTime",
              settingData.enabledUpgradeCabinClassByTime
            )}
            <If value={getFieldValue("enabledUpgradeCabinClassByTime")}>
              {messages("supplier-1.key412") /* 航程时间超过*/}
              <FormItem className="form-item-air-special">
                {getFieldDecorator("upgradeCabinClassHours", {
                  initialValue: settingData.upgradeCabinClassHours || 4,
                })(
                  <Select getPopupContainer={(triggerNode) => triggerNode.parentNode}>
                    {[4, 5, 6, 7, 8, 9, 10].map((item) => (
                      <Option value={item}>
                        {item}
                        {messages("supplier-1.key292") /* 小时*/}
                      </Option>
                    ))}
                  </Select>
                )}
              </FormItem>
              {messages("supplier-1.key413") /* 员工可见商务舱*/}
            </If>
            <br />
            <br />
            <h2>{messages("supplier-1.key414") /* 员工可见机票票价*/}</h2>
            <a className="a-line-bottom">
              {
                messages(
                  "supplier-1.key748"
                ) /*针对同一航段进行比价，若该航段存在公司协议价时，将同时显示协议/非协议最低价*/
              }
            </a>
            <FormItem>
              {getFieldDecorator("visibleTicketPrice", {
                initialValue: settingData.visibleTicketPrice || "",
              })(AirLineUtil.getFormComponent("visibleTicketPrice"))}
            </FormItem>
            <br />
            <br />
            <br />
            <h2>{messages("supplier-1.key749") /*多供应商比价策略*/}</h2>
            <a className="a-line-bottom">{messages("supplier-1.key750") /*同航段供应商排序规则*/}</a>
            <FormItem>
              {getFieldDecorator("sameFlightSegmentSortRule", {
                initialValue: settingData.sameFlightSegmentSortRule || "",
              })(
                <GroupRadio>
                  <Radio value={10}>{messages("supplier-1.key736") /*按含服务费总价从低到高排序*/}</Radio>
                  <Radio value={20}>{messages("supplier-1.key737") /*按机票票面价从低到高排序*/}</Radio>
                </GroupRadio>
              )}
            </FormItem>
            <br />
            <br />
            <a className="a-line-bottom">{messages("supplier-1.key751") /*同价格供应商排序规则*/}</a>
            <FormItem>
              {getFieldDecorator("samePriceSortRule", {
                initialValue: settingData.samePriceSortRule || "",
              })(
                <GroupRadio>
                  <Radio value={10}>{messages("supplier-1.key738") /*随机*/}</Radio>
                  <Radio value={20}>{messages("supplier-1.key739") /*按查询速度优先*/}</Radio>
                  <Radio value={30}>{messages("supplier-1.key740") /*按供应商权重系数优先*/}</Radio>
                  <Radio value={31}>
                    {messages("supplier-1.key741") /*按供应商质量权重优先（并隐藏同价其他供应商）*/}
                  </Radio>
                </GroupRadio>
              )}
            </FormItem>
            <br />
            <br />
            <br />
            <h2>{messages("supplier-1.key752") /*供应商权重系数*/}</h2>
            <a className="a-line-bottom">
              {
                messages(
                  "supplier-1.key753"
                ) /*可配置供应商权重系数，权重系数越高，查询时排序越高。可在【机票服务商】tab下对每个供应商维护权重系数*/
              }
            </a>
            {enabledAirDatas.length > 0 ? (
              enabledAirDatas.map(({ supplierName, qualityWeightCoefficient }) => (
                <div className="quality-weight-coefficient">
                  <span>{`${supplierName}：${qualityWeightCoefficient}`}</span>
                  <br />
                </div>
              ))
            ) : (
              <a>暂无启用供应商</a>
            )}
            <br />
            <br />
            <br />
            <h2>{messages("supplier-1.key415") /* 员工可见机票类型*/}</h2>
            <a className="a-line-bottom">{messages("supplier-1.key416") /* 可见机票类型*/}</a>
            <FormItem>
              {getFieldDecorator("visibleTicketType", {
                initialValue: settingData.visibleTicketType ? settingData.visibleTicketType.split(",") : [],
              })(AirLineUtil.getFormComponent("visibleTicketType"))}
            </FormItem>
            <br />
            <br />
            <h2>{messages("supplier-1.key417") /* 重复预订控制*/}</h2>
            <a className="a-line-bottom">
              {
                messages(
                  "supplier-1.key418"
                ) /* 若同一乘机人存在相似有效机票订单时，禁止下单。【待支付、出票中、出票成功、审批中、待审批】等状态的机票订单为有效单*/
              }
            </a>
            <FormItem>
              {getFieldDecorator("repeatBookingControl", {
                initialValue: settingData.repeatBookingControl || 1002,
              })(
                <GroupRadio>
                  <Radio value={1003}>
                    {
                      messages(
                        "supplier-1.key419"
                      ) /* 按同一天相同航班进行控制（若同一天存在相似航班时会提示乘机人当天存在相同出发地机票）*/
                    }
                  </Radio>
                  <Radio value={1002}>
                    {messages("supplier-1.key420") /* 按同一天相同出发地进行控制（禁止提交）*/}
                  </Radio>
                </GroupRadio>
              )}
            </FormItem>
            <br />
            <br />
            <h2>{messages("supplier-1.key421") /* 前后N小时最低价控制*/}</h2>
            <a>{messages("supplier-1.key422") /* 启用后，可管控员工预订前后N小时最低价*/}</a>
            <a className="a-line-bottom">
              {
                messages(
                  "supplier-1.key423"
                ) /* 强管控：禁止提交；弱管控：需提交理由；二次审批：员工需提交审批，审批通过后，方可出票，审批流程可在表单管理进行设置*/
              }
            </a>

            <FormItem>
              {getFieldDecorator("controlLowestPrice_root", {
                initialValue: {
                  controlLowestPrice: settingData.controlLowestPrice || false,
                  controlLowestPriceWay: settingData.controlLowestPriceWay,
                },
              })(<CheckboxRadio onChange={this.onLowPriceChange} {...AirLineUtil.getPlaneFormItem("lowPrice")} />)}
            </FormItem>

            {isLowPriceControl && (
              <div>
                <FormItem style={{ marginBottom: 12 }}>
                  {getFieldDecorator("airHourWhiteList_root", {
                    rules: [{ validator: this.airWhiteListGroupChecked }],
                    initialValue: {
                      enabledNoControlLowestPrice: settingData.enabledNoControlLowestPrice,
                      noControlLowestPriceGroupId:
                        settingData.noControlLowestPriceGroupId != "all" ? settingData.noControlLowestPriceGroupId : "",
                      noControlLowestPriceGroupId_:
                        settingData.noControlLowestPriceGroupId === "all" ? "all" : "userId",
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("airHourWhiteList")} />)}
                </FormItem>

                <a className="a-line-bottom">{messages("supplier-1.key754") /*比价时间跨度*/}</a>
                {messages("supplier-1.key424") /* 员工所选的航班需为预订时间前后给定时间段内最低价*/}
                <FormItem className="form-item-style" style={{ marginBottom: 6 }}>
                  {getFieldDecorator("inLowestPriceHours", {
                    initialValue: `${settingData.inLowestPriceHours}`,
                  })(AirLineUtil.getFormComponent("priceControlTime"))}
                </FormItem>
                <br />
                <br />
                <FormItem>
                  {getFieldDecorator("reasonForNotLowestPriceList", {
                    initialValue: settingData.reasonForNotLowestPriceList || []
                  })(<ReasonSetting
                    companyOID = {this.props.companyOID}
                    source="airplane"
                    subTitle={messages('supplier-1.key755')/*员工未选择最低价时，可选超标理由*/}
                   />)}
                </FormItem>


                <br />
                <a className="a-line-bottom">{messages("supplier-1.key756") /*航班起飞时间黑名单*/}</a>
                <div className="description-box">
                  {AirLineUtil.singleCheckboxForm(
                    getFieldDecorator,
                    "enabledNoControlLowestPricePeriod",
                    settingData.enabledNoControlLowestPricePeriod,
                    " ",
                    "checkbox-text-null"
                  )}
                  {messages("supplier-1.key425") /* 如果最低价航班出现在*/}
                  <FormItem className="form-item-in-description">
                    {getFieldDecorator("noControlLowestPricePeriodStart", {
                      initialValue: settingData.noControlLowestPricePeriodStart || "22:00",
                    })(
                      <Select getPopupContainer={(triggerNode) => triggerNode.parentNode}>
                        {AirLineUtil.getTimes().map((item) => (
                          <Option value={item.value}>{item.time}</Option>
                        ))}
                      </Select>
                    )}
                    {/* 如果以后需要管控到分钟则使用下面组件，上面的注释*/}
                    {/* {*/}
                    {/* getFieldDecorator('noControlLowestPricePeriodStart', {*/}
                    {/* initialValue: settingData.noControlLowestPricePeriodStart ? moment(settingData.noControlLowestPricePeriodStart, 'HH:mm') : moment('22:00', 'HH:mm'),*/}
                    {/* })(*/}
                    {/* <TimePicker format='HH:mm' style={{width: 100}}/>*/}
                    {/* )*/}
                    {/* }*/}
                  </FormItem>
                  {messages("supplier-1.key426") /* 至*/}
                  <FormItem className="form-item-in-description">
                    {getFieldDecorator("noControlLowestPricePeriodEnd", {
                      initialValue: settingData.noControlLowestPricePeriodEnd || "6:00",
                    })(
                      <Select getPopupContainer={(triggerNode) => triggerNode.parentNode}>
                        {AirLineUtil.getTimes().map((item) => (
                          <Option value={item.value}>{item.time}</Option>
                        ))}
                      </Select>
                    )}
                  </FormItem>
                  {messages("supplier-1.key427") /* 不进行管控*/}
                </div>
                <br />
                <br />
                <a className="a-line-bottom">
                  {messages("supplier-1.key757") /*航司黑名单，黑名单航司将不会进行时段比价*/}
                </a>
                <FormItem>
                  {getFieldDecorator("enabledLowestPriceBlackList", {
                    initialValue: settingData.enabledLowestPriceBlackList,
                    valuePropName: "checked",
                  })(
                    <Checkbox onChange={this.changEnabledLowestPriceBlackList}>
                      {messages("supplier-1.key35") /* 启用temp*/}
                    </Checkbox>
                  )}
                </FormItem>

                {airlineBlackListEnabled &&
                  airlineBlackList.map((value, idx) => (
                    <div>
                      <FormItem
                        key={idx}
                        label={
                          messages("supplier-1.key758", {
                            arg1: idx + 1,
                          }) /*航空公司{arg1}*/
                        }
                        style={{ width: "40%" }}
                      >
                        {getFieldDecorator(`airlineName${idx}`, {
                          initialValue: airlineBlackList[idx],
                          rules: [
                            {
                              required: true,
                              message: messages("supplier-1.key193") /*必填*/,
                            },
                          ],
                        })(<Selector selectorItem={airlineItem} entity onChange={() => this.setAirline(idx)} />)}
                        {!idx && (
                          <div className="plus-circle black-list">
                            <Icon onClick={this.addAirlineBlackList} type="plus-circle" className="plus-icon" />
                          </div>
                        )}
                        {!!idx && (
                          <div className="plus-circle black-list">
                            <Icon
                              onClick={() => this.minusAirlineBlackList(idx)}
                              type="minus-circle"
                              className="plus-icon"
                            />
                          </div>
                        )}
                      </FormItem>
                    </div>
                  ))}
              </div>
            )}
            <br />
            <br />
            <h2>{messages("supplier-1.key217") /* 审批单管控*/}</h2>
            <a>
              {
                messages(
                  "supplier-1.key428"
                ) /* 启用后，员工需提前申请，预订时需关联申请单。提前审批模式不支持该管控方式*/
              }
            </a>
            <a className="a-line-bottom">
              {
                messages(
                  "supplier-1.key423"
                ) /* 强管控：禁止提交；弱管控：需提交理由；二次审批：员工需提交审批，审批通过后，方可出票，审批流程可在表单管理进行设置*/
              }
            </a>
            <FormItem>
              {getFieldDecorator("enabledTravelApprovalControl", {
                initialValue: isOpenApprovalControl,
                valuePropName: "checked",
              })(
                <Checkbox onChange={this.onIsOpenApprovalControl}>
                  {messages("supplier-1.key35") /* 启用temp*/}
                </Checkbox>
              )}
            </FormItem>
            {isOpenApprovalControl && (
              <div>
                <FormItem className="form-item-style" style={{ width: "90%" }}>
                  {getFieldDecorator("_approval", {
                    rules: [{ validator: this.approvalUserGroupChecked }],
                    initialValue: {
                      enabledNoApproval: flightTravelApprlvalControlDto.enabledNoApproval || false,
                      noApprovalUserGroupId_:
                        flightTravelApprlvalControlDto.noApprovalUserGroupId === "all" ? "all" : "userId",
                      noApprovalUserGroupId: flightTravelApprlvalControlDto.noApprovalUserGroupId.replace("all", ""),
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("approval")} />)}
                </FormItem>
                <FormItem>
                  {getFieldDecorator("date_approval", {
                    initialValue: {
                      controlDate: flightTravelApprlvalControlDto.controlDate || false,
                      controlDateWay: flightTravelApprlvalControlDto.controlDateWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("date")} />)}
                </FormItem>
                <FormItem>
                  {getFieldDecorator("people_approval", {
                    initialValue: {
                      controlPassenger: flightTravelApprlvalControlDto.controlPassenger || false,
                      controlPassengerWay: flightTravelApprlvalControlDto.controlPassengerWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("people")} />)}
                </FormItem>
                <FormItem>
                  {getFieldDecorator("address_approval", {
                    initialValue: {
                      controlSite: flightTravelApprlvalControlDto.controlSite,
                      controlSiteWay: flightTravelApprlvalControlDto.controlSiteWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("address")} />)}
                </FormItem>
                <FormItem>
                  {getFieldDecorator("classLevel_approval", {
                    initialValue: {
                      controlCabinClass: flightTravelApprlvalControlDto.controlCabinClass,
                      controlCabinClassWay: flightTravelApprlvalControlDto.controlCabinClassWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("classLevel")} />)}
                </FormItem>
                {getFieldValue("classLevel_approval").controlCabinClass &&
                  AirLineUtil.singleCheckboxForm(
                    getFieldDecorator,
                    "enabledUpgradeCabinClassByTime_approval",
                    flightTravelApprlvalControlDto.enabledUpgradeCabinClassByTime,
                    messages("supplier-1.key429") /* 特殊规则*/,
                    "form-item-air-special2"
                  )}
                <If value={getFieldValue("classLevel_approval").controlCabinClass}>
                  {messages("supplier-1.key430") /* ，航程时间超过*/}
                  <FormItem className="form-item-air-special">
                    {getFieldDecorator("upgradeCabinClassHours_approval", {
                      initialValue: flightTravelApprlvalControlDto.upgradeCabinClassHours || 4,
                    })(
                      <Select getPopupContainer={(triggerNode) => triggerNode.parentNode}>
                        {[4, 5, 6, 7, 8, 9, 10].map((item) => (
                          <Option value={item}>
                            {item}
                            {messages("supplier-1.key292") /* 小时*/}
                          </Option>
                        ))}
                      </Select>
                    )}
                  </FormItem>
                  {messages("supplier-1.key431") /* 员工可超标预订商务舱*/}
                </If>
                <FormItem>
                  {getFieldDecorator("discount_approval", {
                    initialValue: {
                      controlDiscount: flightTravelApprlvalControlDto.controlDiscount,
                      controlDiscountWay: flightTravelApprlvalControlDto.controlDiscountWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("discount")} />)}
                </FormItem>
                <FormItem>
                  {getFieldDecorator("advanceBooking_approval", {
                    initialValue: {
                      controlPreBook: flightTravelApprlvalControlDto.controlPreBook,
                      controlPreBookWay: flightTravelApprlvalControlDto.controlPreBookWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("advanceBooking")} />)}
                </FormItem>
                <FormItem>
                  {getFieldDecorator("amount_approval", {
                    initialValue: {
                      controlPrice: flightTravelApprlvalControlDto.controlPrice,
                      controlPriceWay: flightTravelApprlvalControlDto.controlPriceWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("amount")} />)}
                </FormItem>
              </div>
            )}
            <br />
            <br />
            <h2>{messages("supplier-1.key345") /* 差标管控*/}</h2>
            <a className="a-line-bottom">
              {messages("supplier-1.key433") /* 差标可在【费用与报销管控 - 费控标准-差旅标准】进行设置*/}
            </a>
            <FormItem>
              {getFieldDecorator("enabledTravelStandardsControl", {
                initialValue: isOpenTravelControl,
                valuePropName: "checked",
              })(
                <Checkbox onChange={this.onIsOpenTravelControl}>{messages("supplier-1.key35") /* 启用temp*/}</Checkbox>
              )}
            </FormItem>
            {isOpenTravelControl && (
              <div>
                <FormItem>
                  {getFieldDecorator("classLevel_standard", {
                    initialValue: {
                      controlCabinClass: flightTravelStandardsControlDto.controlCabinClass,
                      controlCabinClassWay: flightTravelStandardsControlDto.controlCabinClassWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("classLevel")} />)}
                </FormItem>
                {getFieldValue("classLevel_standard").controlCabinClass &&
                  AirLineUtil.singleCheckboxForm(
                    getFieldDecorator,
                    "enabledUpgradeCabinClassByTime_standard",
                    flightTravelStandardsControlDto.enabledUpgradeCabinClassByTime,
                    messages("supplier-1.key429") /* 特殊规则*/,
                    "form-item-air-special2"
                  )}
                <If value={getFieldValue("classLevel_standard").controlCabinClass}>
                  {messages("supplier-1.key430") /* ，航程时间超过*/}
                  <FormItem className="form-item-air-special">
                    {getFieldDecorator("upgradeCabinClassHours_standard", {
                      initialValue: flightTravelStandardsControlDto.upgradeCabinClassHours || 4,
                    })(
                      <Select getPopupContainer={(triggerNode) => triggerNode.parentNode}>
                        {[4, 5, 6, 7, 8, 9, 10].map((item) => (
                          <Option value={item}>
                            {item}
                            {messages("supplier-1.key292") /* 小时*/}
                          </Option>
                        ))}
                      </Select>
                    )}
                  </FormItem>
                  {messages("supplier-1.key431") /* 员工可超标预订商务舱*/}
                </If>
                <FormItem>
                  {getFieldDecorator("discount_standard", {
                    initialValue: {
                      controlDiscount: flightTravelStandardsControlDto.controlDiscount,
                      controlDiscountWay: flightTravelStandardsControlDto.controlDiscountWay,
                    },
                  })(<CheckboxRadio {...AirLineUtil.getPlaneFormItem("discount")} />)}
                </FormItem>
              </div>
            )}
            <br />
            <br />
            <h2>{messages("supplier-1.key434") /* 超标审批撤回权限*/}</h2>
            <a className="a-line-bottom">{messages("supplier-1.key435") /* 提交审批后，预订人是否可撤回审批*/}</a>
            <FormItem>
              {getFieldDecorator("cancelApprovalWay", {
                initialValue: settingData.cancelApprovalWay || "always",
              })(
                <GroupRadio>
                  <Radio value="always">{messages("supplier-1.key436") /* 始终允许撤回*/}</Radio>
                  <Radio value="never">{messages("supplier-1.key437") /* 始终不允许撤回*/}</Radio>
                </GroupRadio>
              )}
            </FormItem>
            <br />
            <br />
            <FormItem>
              {getFieldDecorator("reasonForBeyondStandardsList", {
                initialValue: settingData.reasonForBeyondStandardsList || []
              })(<ReasonSetting
                title={messages("supplier-1.key438") /* 超标理由*/}
                subTitle={messages('supplier-1.key852')/*员工可选超标理由*/}
                source="airplane"
                companyOID = {this.props.companyOID}
               />)}
             </FormItem>


            <h2>{messages('supplier-1.key440')/*超标提示语*/}</h2>
            <a className="a-line-bottom">超标提示语：自定义公司超标提示语</a>

            <FormItem>
              {getFieldDecorator("promptForBeyondStandards", {
                initialValue: settingData.promptForBeyondStandards || "",
              })(<TextArea placeholder={messages("supplier-1.key440") /* 超标提示语*/} />)}
            </FormItem>

          </Form>
          }



          <br />
          <br />
          <br />
          <br />
          <br />
        </Spin>
        <Affix offsetBottom={0} className="setting-fotter-class">
          <Button style={{ marginLeft: 20 }} type="primary" onClick={this.onSaveSetting}>
            {messages("supplier-1.key356") /* 保存配置*/}
          </Button>
        </Affix>
      </div>
    );
  }
}

export default SetTravelControl;
